<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>扩展运算符 【...】</title>
</head>
<body>
	<div></div>
	<div></div>
	<div></div>
	
	<script>
		// [...] 扩展运算符能将 【数组】 转换为逗号分隔的 【参数序列】
		
		const arr = [1,2,3,4];

		function demo(){
			console.log(arguments);
		}
		demo(...arr);

		// 扩展运算符应用
		// 1. 数组的合并
		let kuaizi = ['王太利', '肖央'];
		let fenghuang = ['曾毅', '玲花'];

		// es 6
		let zuixuanxiaopingguo = [...kuaizi, ...fenghuang];
		console.log(zuixuanxiaopingguo);

		// 2. 数组的克隆（浅拷贝）
		let sanzhihua = ['E', 'G', 'M'];
		let sanyecao = [...sanzhihua];
		console.log(sanyecao);

		// 3. 将伪数组转为真正的数组
		let divs = document.querySelectorAll('div');
		let divArr = [...divs];
		console.log(divArr);
	</script>
</body>
</html>